﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using Data;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {

    }
    /// <summary>
    /// Handles the Authenticate event of the Login control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Web.UI.WebControls.AuthenticateEventArgs"/> instance containing the event data.</param>
    /// <return>
    /// athentication true if the user login data match, false otherwise
    /// </return>
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) {
        AdminLogin_Data userlog = new AdminLogin_Data();
        AdminLogin_Business objlogin = new AdminLogin_Business();
        Encryption objenc = new Encryption();
        //retreive username and encrypted password from the textbox 
        userlog.UserName = Login1.UserName;
        userlog.Password = objenc.EncryptString(Login1.Password);
        if (objlogin.AdminLogin(userlog).Equals(true)) {
            e.Authenticated = true;
            //Create new session of "username"
            Session["username"] = Login1.UserName;
            //Server.Transfer("admin/Home.aspx");
        } else {
            e.Authenticated = false;
        }
    }
}
